package Entity;

import java.io.Serializable;
import Communication.Client;
import Communication.MessageHandle;

/** this class Create new Instance of worker*/

public class Worker implements Serializable {
	
	//private static final long serialVersionUID = 42L;
	
	/**attributes for pattern*/
	String WorkerID;		
	String firstName;
	String lastName;
	String email;
	String username;
	String password;
    int status;		
    int Role;
     
    /**default constructor*/
	public Worker()
	{
		
	}
	
	/**constructor with attributes*/
	public Worker(String WorkerID,int Role)
	{
		this.Role=Role;
		this.WorkerID=WorkerID;
	}
	
	/**Full constructor with all attributes*/
	public Worker(String WorkerID,String username,String firstName,String lastName,String emailAddress,String Password, int Role,int Status)
	{		
		this.WorkerID=WorkerID;
		this.username=username;
		this.email=emailAddress;
		this.firstName=firstName;
		this.lastName=lastName;
		this.password=Password;
		this.Role=Role;
		this.status=Status;
	}

	/**get functions*/
	public String getWorkerID()
	{
		return this.WorkerID;
	}
	
	public String getusername()
	{
		return this.username;
	}
	
	public String getfirstName()
	{
		return this.firstName;
	}
	
	public String getlastName()
	{
		return this.lastName;
	}
	
	public String getEmail()
	{
		return this.email;
	}
	
	public int getRole()
	{
		return this.Role;
	}
	
	public int getStatus()
	{
		return this.status;
	}
	
	public String getPassword()
	{
		return this.password;
	}
	
	public void getWorkerFromDB(Client client, String username) 
	{	
		String workerQuery = "SELECT * FROM workers WHERE UserName = " + "\"" + username + "\"";
		client.getData(workerQuery, MessageHandle.WORKER, false);				
	}
	
	/**set functions*/
	public void setStatusDB(Client client, int status) 
	{			
		String workerID = client.getCurrentWorker().getWorkerID();
		String StatusQuery = "UPDATE workers SET Status = " +  status + " WHERE WorkerID =" + "\"" + workerID + "\"";
		client.getData(StatusQuery, MessageHandle.WORKER, true);
	}
	
	public void setWorkerID(String workerID) 
	{
		this.WorkerID = workerID;
	}
	
	public void setFirstName(String firstName) 
	{
		this.firstName = firstName;
	}
	
	public void setLastName(String lastName) 
	{
		this.lastName = lastName;
	}
	
	public void setEmail(String email) 
	{
		this.email = email;
	}
	
	public void setUsername(String username) 
	{
		this.username = username;
	}
	
	public void setPassword(String password) 
	{
		this.password = password;
	}
	
	public void setRole(int role) 
	{
		Role = role;
	}	
	public void SetStatus(int status)
	{
		
	}
		
}	
	